package com.hulytu.invasion;

import android.os.Bundle;
import android.util.ArrayMap;

import com.hulytu.invasion.core.BuildConfig;

import java.util.Map;

/**
 * 基础配置
 */
public class Planet {

    // 默认的全局配置
    public static final Planet DEFAULT = new Planet();

    private final Map<String, Object> configs = new ArrayMap<>();

    private final Bundle bundle = new Bundle();

    private boolean debuggable = BuildConfig.DEBUG;
    private boolean loggable = BuildConfig.DEBUG;

    public void setDebuggable(boolean debuggable) {
        this.debuggable = debuggable;
    }

    public void setLoggable(boolean loggable) {
        this.loggable = loggable;
    }

    /**
     * 是否是debug模式
     *
     * @return
     */
    public boolean isDebuggable() {
        return debuggable;
    }

    /**
     * 是否输出日志
     *
     * @return
     */
    public boolean isLoggable() {
        return loggable;
    }

    public void putBoolean(String key, boolean value) {
        bundle.putBoolean(key, value);
    }

    public void putByte(String key, byte value) {
        bundle.putByte(key, value);
    }

    public void putChar(String key, char value) {
        bundle.putChar(key, value);
    }

    public void putShort(String key, short value) {
        bundle.putShort(key, value);
    }

    public void putInt(String key, int value) {
        bundle.putInt(key, value);
    }

    public void putLong(String key, long value) {
        bundle.putLong(key, value);
    }

    public void putFloat(String key, float value) {
        bundle.putFloat(key, value);
    }

    public void putDouble(String key, double value) {
        bundle.putDouble(key, value);
    }

    public void putCharSequence(String key, CharSequence value) {
        bundle.putCharSequence(key, value);
    }

    public void putObject(String key, Object value) {
        configs.put(key, value);
    }

    public boolean getBoolean(String key, boolean def) {
        return bundle.getBoolean(key, def);
    }

    public byte getByte(String key, byte def) {
        return bundle.getByte(key, def);
    }

    public char getChar(String key, char defaultValue) {
        return bundle.getChar(key, defaultValue);
    }

    public short getShort(String key, short defaultValue) {
        return bundle.getShort(key, defaultValue);
    }

    public int getInt(String key, int defaultValue) {
        return bundle.getInt(key, defaultValue);
    }

    public long getLong(String key, long defaultValue) {
        return bundle.getLong(key, defaultValue);
    }

    public float getFloat(String key, float defaultValue) {
        return bundle.getFloat(key, defaultValue);
    }

    public double getDouble(String key, double defaultValue) {
        return bundle.getDouble(key, defaultValue);
    }

    public CharSequence getCharSequence(String key, CharSequence defaultValue) {
        return bundle.getCharSequence(key, defaultValue);
    }

    public Object getObject(String key) {
        return configs.get(key);
    }
}
